<template>
  <div v-loading="loading">
    <div class="top">
      <p>免费查询版权是否能注册</p>
      <div>
        <el-input placeholder="请输入您要查询的版权名称" class="input-with-select">
          <el-button slot="append" @click="dialogFormVisible = true">查询</el-button>
        </el-input>
      </div>
    </div>
    <div class="content">
      <div class="title">
        <img src="../assets/image/titleL.png" width="500" alt="" title=""/>
        <span>版权分类</span>
        <img src="../assets/image/titleR.png" width="500" alt="" title=""/>
      </div>
      <div class="fL">
        <el-tabs :tab-position="tabPosition" v-model="activeName" @tab-click="handleClick">
          <el-tab-pane :label="classify.name"
                       :name="classify.name"
                       v-for="(classify,index) in banQuanALclassify"
                       :key="index">
            <div class="sbList">
              <div class="sb1 display-flex justify-content align-items" v-for="(list,index) in banQuanALListData" :key="index">
                <img :src="list.image" width="190" alt="" title=""/>
                <div class="sb1Show">{{list.name}}</div>
              </div>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </div>
    <div class="hzqy sbjs">
      <div>
        <div class="title">
          <img src="../assets/image/titleL2.png" width="500" alt="" title=""/>
          <span>版权介绍</span>
          <img src="../assets/image/titleR2.png" width="500" alt="" title=""/>
        </div>

        <div class="display-flex space-between flex-item">
          <el-card class="box-card" v-for="(jieshao,index) in shangBiaojsData" :key="index">
            <div class="text item">
              <img :src="jieshao.image" height="75" alt="" title=""/>
              <p>{{jieshao.name}}</p>
              <p>{{jieshao.description}}</p>
            </div>
          </el-card>
        </div>
      </div>
    </div>
    <div class="content">
      <div class="title">
        <img src="../assets/image/titleL.png" width="500" alt="" title=""/>
        <span>版权服务</span>
        <img src="../assets/image/titleR.png" width="500" alt="" title=""/>
      </div>
      <div class="display-flex space-between flex-item">
        <div class="sbfw" v-for="(list,index) in shangBiaofwData" :key="index">
          <p><img :src="list.image" height="40" :alt="list.name" title=""/>{{list.name}}</p>
          <p>{{list.description}}</p>
        </div>
      </div>
    </div>
    <div class="SBZS SBAL">
      <div class="title">
        <img src="../assets/image/titleL.png" width="500" alt="" title=""/>
        <span>版权案例</span>
        <img src="../assets/image/titleR.png" width="500" alt="" title=""/>
      </div>
      <el-tabs v-model="activeName2" @tab-click="handleClick2">
        <el-tab-pane :label="classify.name"
                     :name="classify.name"
                     v-for="(classify,index) in banQuanALclassify"
                     :key="index">
          <el-row :gutter="20">
            <el-col :span="6" v-for="(list,index) in banQuanALListData2" :key="index">
              <div class="grid-content">
                <el-card class="box-card">
                  <div class="text item">
                    <img :src="list.image" width="190" :alt="list.name" title=""/>
                    <p>{{list.name}}</p>
                    <p>{{list.description}}</p>
                  </div>
                </el-card>
              </div>
            </el-col>
          </el-row>
        </el-tab-pane>
      </el-tabs>
    </div>

    <!--查询弹出框-->
    <el-dialog title="免费查询" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item>
          <el-input prefix-icon="el-icon-search" v-model="form.name" placeholder="请输入查询内容"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input prefix-icon="el-icon-mobile" v-model="form.phone" placeholder="请输入手机号码"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <!--<el-button @click="dialogFormVisible = false">取 消</el-button>-->
        <el-button type="primary" @click="hide">免费查询</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    name: "bqfw",
    data() {
      return {
        loading: false,
        activeName: '',
        activeName2: '',
        tabPosition: 'left',

        shangBiaofwID: 0,
        shangBiaofwData:[],
        shangBiaojsID: 0,
        shangBiaojsData:[],

        banQuanALclassify:[],
        banQuanALListData:[],
        banQuanALListData2:[],

        dialogFormVisible: false,
        form: {
          name: '',
          phone:'',
        },
      }
    },
    methods: {
      handleClick(tab) {
        // console.log(tab.index);
        var id = this.banQuanALclassify[tab.index].id;
        this.banQuanALlist(id,1)
      },
      handleClick2(tab) {
        // console.log(tab.index);
        var id = this.banQuanALclassify[tab.index].id;
        this.banQuanALlist(id,2)
      },

      //每屏列表(获取商标服务详情,获取商标介绍详情)
      getClassifyData(id) {
        let that = this;
        this.$http
          .post(this.$api.default.MP,{cid : id},)
          .then(res => {
            // console.log('数据', res);
            for(var i = 0;i < res.data.length;i++){
              res.data[i].image = that.$api.default.url_ + res.data[i].image
            }
            if(id === that.shangBiaofwID){
              that.shangBiaofwData = res.data;
            }else if(id === that.shangBiaojsID){
              that.shangBiaojsData = res.data;
            }
          }).catch(error => {
        })
          .then(() => {
          });
      },
      //每屏分类(获取商标服务ID,获取商标介绍ID)
      getClassifyList() {
        this.shangBiaofwID = localStorage.getItem('shangBiaofwID');
        if(this.shangBiaofwID){
          this.getClassifyData(this.shangBiaofwID)
          return
        }
        // console.log('请求LOGO');
        let that = this;
        this.$http
          .post(this.$api.default.MPFL,{type : 'screen'},)
          .then(res => {
            // console.log('数据', res);
            //商标服务ID
            if(res.data[2].name == '商标服务'){
              that.shangBiaofwID = res.data[2].id;
              localStorage.setItem('shangBiaofwID',res.data[2].id);
              that.getClassifyData(that.shangBiaofwID)
            }
            //商标介绍ID
            if(res.data[1].name == '商标介绍'){
              that.shangBiaojsID = res.data[1].id;
              localStorage.setItem('shangBiaojsID',res.data[1].id);
              that.getClassifyData(that.shangBiaojsID)
            }
          }).catch(error => {
        })
          .then(() => {
          });
      },


      //案例--版权案例
      banQuanAL(){
        let that = this;
        this.$http
          .post(this.$api.default.category,{type:'copyright'},)
          .then(res => {
            // console.log('数据', res)
            that.banQuanALclassify = res.data;
            //设置初始值
            that.activeName = res.data[0].name
            that.activeName2 = res.data[0].name
            that.banQuanALlist(res.data[0].id,3)

          }).catch(error => {
        })
          .then(() => {
          });
      },
      //案例--版权列表
      banQuanALlist(id,who){
        // console.log(id)
        let that = this;
        this.$http
          .post(this.$api.default.BQ,{page: 1,cid: id,listRows: 8})
          .then(res => {
            // console.log('数据', res);

            for(var i = 0;i < res.data.data.length;i++){
              res.data.data[i].image = that.$api.default.url_ + res.data.data[i].image
            }
            if(who == 1){
              that.banQuanALListData = res.data.data;
            }else if(who == 2){
              that.banQuanALListData2 = res.data.data;
            }else if(who == 3){
              that.banQuanALListData = res.data.data;
              that.banQuanALListData2 = res.data.data;
            }

          }).catch(error => {
        })
          .then(() => {
          });
      },
      //弹框
      hide(){
        var name_ = '版权';
        if(!this.form.name){
          this.toast('error', '查找内容为空', true);
          return;
        }
        if(!this.check.isMobile(this.form.phone)){
          this.toast('error', '请正确填写手机号码', true);
          return;
        }
        let that = this;

        this.$http
          .post(this.$api.default.message,{name: name_,ipr_name: that.form.name,phone: that.form.phone},)
          .then(res => {
            // console.log('数据', res);

            this.toast('success', '提交成功', true);
            this.dialogFormVisible = false;
            this.form.name = '';
            this.form.phone = '';

          }).catch(error => {
        })
          .then(() => {
          });
      },
    },
    //生命周期 - 创建完成（可以访问当前this实例）
    created() {
      //商标服务
      this.shangBiaofwID = localStorage.getItem('shangBiaofwID');
      if(this.shangBiaofwID){
        this.getClassifyData(this.shangBiaofwID);
      }else {
        this.getClassifyList();
      }
      //商标介绍
      this.shangBiaojsID = localStorage.getItem('shangBiaojsID');
      if(this.shangBiaojsID){
        this.getClassifyData(this.shangBiaojsID);
      }else {
        this.getClassifyList();
      }

      //版权案例
      this.banQuanAL();
    },
    //生命周期 - 挂载完成（可以访问DOM元素）
    mounted() {}, //生命周期 - 创建之前
    beforeCreate() {},
    //生命周期 - 挂载之前
    beforeMount() {},
    //生命周期 - 更新之前
    beforeUpdate() {},
    //生命周期 - 更新之后
    updated() {},
    //生命周期 - 销毁之前
    beforeDestroy() {},
    //生命周期 - 销毁完成
    destroyed() {},
    //如果页面有keep-alive缓存功能，这个函数会触发
    activated() {},
  }
</script>

<style scoped>
  .top{
    height: 500px;
    min-width: 1200px;
    padding-top: 113px;
    background: url("../assets/image/banner2.png") no-repeat;
    background-position: center center;
    background-size: cover;
    box-sizing: border-box;
  }
  .top p{
    font-size: 50px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    color: #FFFFFF;
    line-height: 60px;
    text-align: center;
    margin-bottom: 60px;
  }
  .content{
    width: 1200px;
    margin: auto;
  }
  .top >>> .el-tabs__nav-wrap::after{
    display: none;
  }
  .top >>> .el-tabs__item{
    width: 98px;
    height: 40px;
    border-radius: 6px;
    font-size: 24px;
    color: #fff;
    line-height: 40px;
    text-align: center;
    padding: 0px;
  }
  .top >>> .el-tabs__item.is-active{
    background: #FFFFFF;
    color: #1890FF;
  }
  .top >>> .el-tabs__active-bar{
    display: none;
  }
  .top >>> .el-tabs__nav{
    float: none;
    /*margin: auto;*/
    text-align: center;
  }
  .top >>> .el-tabs__content{
    width: 1200px;
    margin: auto;
  }
  .top >>> .el-input-group{
    width: 800px;
    margin: auto;
  }
  .title{
    text-align: center;
    font-size: 32px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    color: #1890FF;
    /*line-height: 84px;*/
    margin: 70px 0;
  }
  .title span{
    display: inline-block;
    margin: 0 20px;
  }
  .top >>> .el-input-group__append{
    background-color: #1890FF;
    color: #FFFFFF;
    font-size: 22px;
    border: none;
  }
  .top >>> .el-input__inner{
    height: 60px;
    font-size: 18px;
  }
  .fL{
    height: 500px;
    border-radius: 10px;
    border: 1px solid #B7B7B7;
    overflow: auto;
    margin-bottom: 60px;
  }
  .fL >>> .el-tabs--left,
  .fL >>> .el-tabs__content,
  .fL >>> .el-tabs__content .el-tab-pane{
    height: 100%;
  }
  .el-tabs--left >>> .el-tabs__header.is-left{
    width: 180px;
    margin-right: 0;
    background: url("../assets/image/bg_z2.png") no-repeat;
    background-position: center center;
    background-size: cover;
    padding-top: 20px;
    box-sizing: border-box;
  }
  .el-tabs--left >>> .el-tabs__active-bar.is-left{
    display: none;
  }
  .el-tabs--left >>> .el-tabs__item.is-left{
    width: 128px;
    background: #FFFFFF;
    margin: auto;
    margin-bottom: 20px;
    border-radius: 6px;
    text-align: center;
    font-size: 16px;
  }
  .left p{
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    color: #FFFFFF;
    margin-top: 50px;
    margin-bottom: 25px;
  }
  .classify{
    width: 244px;
    height: 231px;
    background: #FFFFFF;
    border-radius: 10px;
    margin: auto;
    padding: 20px;
    box-sizing: border-box;
  }
  .classify ul li{
    width: 33%;
    margin-bottom: 28px;
    cursor: pointer;
  }
  .classify ul li:hover{
    color: #1890FF;
  }
  .left .el-input{
    width: 244px;
    margin: auto;
    display: block;
    margin-bottom: 100px;

  }
  .right{
    width: calc(100% - 300px);
    height: 500px;
    float: left;
  }
  .sbList{
    height: 50%;
  }
  .sbList .sb1{
    float: left;
    width: 25%;
    height: 100%;
    position: relative;
    border: 1px solid #B7B7B7;
    box-sizing: border-box;
  }
  .sbList .sb1 .sb1Show{
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 40px;
    background: #1890FF;
    font-size: 18px;
    color: #FFFFFF;
    line-height: 40px;
    text-align: center;
    display: none;
  }
  .sbList .sb1:hover{
    border: 1px solid #1890FF;
  }
  .sbList .sb1:hover .sb1Show{
    display: block;
  }
  .el-carousel__item h3 {
    color: #475669;
    font-size: 18px;
    opacity: 0.75;
    line-height: 300px;
    margin: 0;
  }
  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }
  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }
  .hzqy{
    background: #1890FF;
    min-width: 1200px;
    margin: auto;
  }
  .hzqy .title{
    color: #fff;
    padding-top: 70px;
  }
  .hzqy > div{
    width: 1200px;
    margin: auto;
  }
  .hzqy >>> .el-carousel__item{
    background: transparent;
  }
  .sbjs >>> .el-card{
    width: 330px;
    height: 350px;
    box-sizing: border-box;
  }
  .sbjs{
    padding-bottom: 80px;
  }
  .sbjs .box-card p:nth-of-type(1){
    color: #333333;
    font-weight: bold;
    font-size: 18px;
  }
  .sbjs .box-card p:nth-of-type(2){
    color: #666666;
    font-size: 16px;
    text-align: center;
    line-height: 26px;
  }
  .sbjs  .box-card img{
    margin-bottom: 22px;
  }
  .hzqy >>> .el-carousel__arrow--left,
  .hzqy >>> .el-carousel__arrow--right{
    background: #fff;
    box-shadow: 0px 0px 4px 4px #ddd;
  }
  .hzqy >>> .el-card__body{
    padding: 65px;
  }
  .sbfw{
    width: 250px;
  }
  .sbfw p:nth-of-type(1){
    line-height: 40px;
    font-weight: bold;
    color: #333333;
    font-size: 20px;
  }
  .sbfw p:nth-of-type(2){
    font-size: 16px;
    font-weight: 400;
    color: #666666;
    line-height: 26px;
    margin-top: 10px;
  }
  .sbfw img{
    vertical-align: middle;
    margin-right: 10px;
  }
  .SBAL{
    margin-top: 80px;
    background: #F6F7F9;
  }
  .SBAL >>> .el-tabs{
    width: 1200px;
    margin: auto;
  }
  .SBAL >>> .el-tabs__content{
    padding-bottom: 50px;
  }
  .SBAL .title{
    padding-top: 70px;
    margin: 0;
    margin-bottom: 70px;
  }
  .box-card img{
    display: block;
    margin: auto;
    margin-bottom: 30px;
  }
  .box-card p:nth-of-type(1){
    text-align: center;
    margin-bottom: 15px;
  }
  .SBZS >>> .el-tabs__nav-scroll{
    padding-left: 50px;
  }
  .SBZS >>> .el-tabs__item{
    font-size: 18px;
  }
  .SBZS >>> .el-tabs__header{
    margin-bottom: 60px;
  }
  .SBZS .el-col-6{
    margin-bottom: 30px;
  }
  .top > div{
    text-align: center;
  }
</style>
